<?php
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
global $table_prefix, $wpdb;
$idcat = $_GET['cat'];

$q = "SELECT term_id 
	FROM wp_terms, wp_term_taxonomy
	WHERE wp_terms.term_id = wp_term_taxonomy.term_id
	AND parent =".$idcat;
$r = $wpdb->get_results($q);
$city ="";
	foreach($r as $id){ 
       $city = $id->term_id;
    }
$risposta = "<div class='tab_content' style='display: block;'>";
$custom_query = new WP_Query('cat='.$idcat.','.$city.'&post_parent=0&posts_per_page=4'); 
while($custom_query->have_posts()) : $custom_query->the_post();
	$risposta.="<div id='image'>"."<a href=".the_permalink()."><img style='width: 170px; height: 250px;' src=".catch_that_image()."></a></div>";
endwhile;
	$risposta.="</div></div>";
echo $risposta;

?>